GO
/****** Object:  Table [Role_Preference]    Script Date: 01/27/2011 17:47:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [Role_Preference](
	[idRolePreference] [int] IDENTITY(1,1) NOT NULL,
	[idRole] [int] NOT NULL,
	[IdPreference] [int] NOT NULL,
 CONSTRAINT [PK_Role_Preference] PRIMARY KEY CLUSTERED 
(
	[idRolePreference] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [Preference]    Script Date: 01/27/2011 17:47:56 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [Preference](
	[idPreference] [int] IDENTITY(1,1) NOT NULL,
	[name] [varchar](50) NOT NULL,
	[description] [varchar](50) NULL,
	[id] [varchar](50) NOT NULL,
 CONSTRAINT [PK_Preference] PRIMARY KEY CLUSTERED 
(
	[idPreference] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [Permission]    Script Date: 01/27/2011 17:47:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [Permission](
	[idPermission] [int] IDENTITY(1,1) NOT NULL,
	[name] [varchar](50) NOT NULL,
	[description] [varchar](255) NULL,
	[id] [varchar](50) NOT NULL,
 CONSTRAINT [PK_Permissions] PRIMARY KEY CLUSTERED 
(
	[idPermission] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [User]    Script Date: 01/27/2011 17:48:04 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [User](
	[idUser] [int] IDENTITY(1,1) NOT NULL,
	[status] [int] NOT NULL,
	[editable] [bit] NULL,
	[username] [varchar](200) NOT NULL,
	[password] [varchar](200) NOT NULL,
	[email] [nvarchar](255) NOT NULL,
	[uuid] [nvarchar](50) NOT NULL,
	[name] [nvarchar](50) NOT NULL,
	[shortdescription] [nvarchar](max) NULL,
	[description] [ntext] NULL,
 CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED 
(
	[idUser] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [Comment]    Script Date: 01/27/2011 17:47:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [Comment](
	[idComment] [int] IDENTITY(1,1) NOT NULL,
	[idPost] [int] NOT NULL,
	[status] [bit] NOT NULL CONSTRAINT [DF_Comment_status]  DEFAULT ((1)),
	[postdate] [datetime] NOT NULL,
	[uuid] [varchar](50) NOT NULL,
	[name] [nvarchar](255) NOT NULL,
	[email] [nvarchar](255) NOT NULL,
	[website] [nvarchar](255) NULL,
	[comment] [nvarchar](max) NOT NULL,
 CONSTRAINT [PK_Comment] PRIMARY KEY CLUSTERED 
(
	[idComment] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [Role]    Script Date: 01/27/2011 17:47:57 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [Role](
	[idRole] [int] IDENTITY(1,1) NOT NULL,
	[name] [nvarchar](50) NOT NULL,
	[description] [nvarchar](255) NULL,
 CONSTRAINT [PK_Roles] PRIMARY KEY CLUSTERED 
(
	[idRole] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [Category]    Script Date: 01/27/2011 17:47:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [Category](
	[idCategory] [int] IDENTITY(1,1) NOT NULL,
	[name] [nvarchar](255) NOT NULL,
	[description] [nvarchar](max) NULL,
	[uuid] [varchar](50) NOT NULL,
 CONSTRAINT [PK_Category] PRIMARY KEY CLUSTERED 
(
	[idCategory] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [Post_Category]    Script Date: 01/27/2011 17:47:55 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [Post_Category](
	[idPost] [int] NOT NULL,
	[idCategory] [int] NOT NULL
) ON [PRIMARY]
GO
/****** Object:  Table [Post]    Script Date: 01/27/2011 17:47:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [Post](
	[idPost] [int] IDENTITY(1,1) NOT NULL,
	[authorId] [int] NOT NULL,
	[status] [int] NULL CONSTRAINT [DF_Post_status]  DEFAULT ((0)),
	[allowComment] [bit] NULL,
	[publishingDate] [datetime] NOT NULL,
	[uuid] [varchar](50) NOT NULL,
	[title] [nvarchar](250) NOT NULL,
	[urlSafe] [nvarchar](255) NULL,
	[mainContent] [nvarchar](max) NOT NULL,
	[excerpt] [nvarchar](max) NULL,
 CONSTRAINT [PK_Post] PRIMARY KEY CLUSTERED 
(
	[idPost] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [Blog]    Script Date: 01/27/2011 17:47:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [Blog](
	[idBlog] [varchar](50) NOT NULL,
	[title] [nvarchar](255) NOT NULL,
	[description] [nvarchar](max) NULL,
	[tagline] [nvarchar](255) NULL,
	[link] [nvarchar](255) NULL,
 CONSTRAINT [PK_Blog] PRIMARY KEY CLUSTERED 
(
	[idBlog] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [Setting]    Script Date: 01/27/2011 17:48:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [Setting](
	[idSetting] [int] IDENTITY(1,1) NOT NULL,
	[idBlog] [varchar](50) NOT NULL,
	[maxrow] [int] NOT NULL,
 CONSTRAINT [PK_Setting] PRIMARY KEY CLUSTERED 
(
	[idSetting] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [Skin]    Script Date: 01/27/2011 17:48:01 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [Skin](
	[idSkin] [int] IDENTITY(1,1) NOT NULL,
	[name] [nvarchar](255) NOT NULL,
	[description] [nvarchar](255) NULL,
	[status] [bit] NOT NULL,
	[idBlog] [varchar](50) NULL,
 CONSTRAINT [PK_Skin] PRIMARY KEY CLUSTERED 
(
	[idSkin] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [Role_Permission]    Script Date: 01/27/2011 17:47:58 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [Role_Permission](
	[idRolePermission] [int] IDENTITY(1,1) NOT NULL,
	[idRole] [int] NOT NULL,
	[idPermission] [int] NOT NULL,
 CONSTRAINT [PK_Role_Permission] PRIMARY KEY CLUSTERED 
(
	[idRolePermission] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [User_Role]    Script Date: 01/27/2011 17:48:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [User_Role](
	[idUserRole] [int] IDENTITY(1,1) NOT NULL,
	[idUser] [int] NOT NULL,
	[idRole] [int] NOT NULL,
 CONSTRAINT [PK_User_Role] PRIMARY KEY CLUSTERED 
(
	[idUserRole] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  ForeignKey [FK_Roles_Permissions_Permissions]    Script Date: 01/27/2011 17:47:58 ******/
ALTER TABLE [Role_Permission]  WITH CHECK ADD  CONSTRAINT [FK_Roles_Permissions_Permissions] FOREIGN KEY([idPermission])
REFERENCES [Permission] ([idPermission])
ON DELETE CASCADE
GO
ALTER TABLE [Role_Permission] CHECK CONSTRAINT [FK_Roles_Permissions_Permissions]
GO
/****** Object:  ForeignKey [FK_Roles_Permissions_Roles]    Script Date: 01/27/2011 17:47:58 ******/
ALTER TABLE [Role_Permission]  WITH CHECK ADD  CONSTRAINT [FK_Roles_Permissions_Roles] FOREIGN KEY([idRole])
REFERENCES [Role] ([idRole])
ON DELETE CASCADE
GO
ALTER TABLE [Role_Permission] CHECK CONSTRAINT [FK_Roles_Permissions_Roles]
GO
/****** Object:  ForeignKey [FK_Users_Roles_Roles]    Script Date: 01/27/2011 17:48:05 ******/
ALTER TABLE [User_Role]  WITH CHECK ADD  CONSTRAINT [FK_Users_Roles_Roles] FOREIGN KEY([idRole])
REFERENCES [Role] ([idRole])
ON DELETE CASCADE
GO
ALTER TABLE [User_Role] CHECK CONSTRAINT [FK_Users_Roles_Roles]
GO
/****** Object:  ForeignKey [FK_Users_Roles_Users]    Script Date: 01/27/2011 17:48:05 ******/
ALTER TABLE [User_Role]  WITH CHECK ADD  CONSTRAINT [FK_Users_Roles_Users] FOREIGN KEY([idUser])
REFERENCES [User] ([idUser])
ON DELETE CASCADE
GO
ALTER TABLE [User_Role] CHECK CONSTRAINT [FK_Users_Roles_Users]
GO
